package com.gitee.wsl.compose.mvi.ui.textbutton

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.InteractionSourceProjector
import com.gitee.wsl.compose.mvi.ui.button.ButtonProjector
import com.gitee.wsl.compose.mvi.ui.text.TextProjector


class TextButtonProjector(
    interactor: TextButtonInteractor,
    presenter: TextButtonPresenter
) : InteractionSourceProjector<TextButtonInteractor, TextButtonPresenter>(interactor, presenter) {

    @Composable
    override fun body(
        combinedModifier: Modifier,
        interactor: TextButtonInteractor,
        presenter: TextButtonPresenter,
        interactionSource: MutableInteractionSource,
    ) {
        val buttonProjector = ButtonProjector(interactor.button, presenter.button)
        val textProjector = TextProjector(interactor.text, presenter.text)

        buttonProjector(
            modifier = combinedModifier,
            interactionSource = interactionSource
        ) {
            textProjector()
        }
    }
}